<template>
  <el-dropdown @command="handleCommand">
    <span class="el-dropdown-link">

      <item icon="language" />
    </span>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item :disabled="lang==='zh'" command="zh">中文</el-dropdown-item>
      <el-dropdown-item :disabled="lang==='en'" command="en">En</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookies from 'js-cookie'
import Item from '@/layout/components/Sidebar/Item.vue'
export default {
  components: { Item },
  data() {
    return {
      lang: Cookies.get('lang') || 'zh'
    }
  },
  methods: {
    handleCommand(command) {
      this.lang = command
      this.$i18n.locale = this.lang
      Cookies.set('lang', this.lang)
    }
  }
}
</script>

<style>
.svg-icon{
  margin-left: 10px;
  font-size: 25px!important;
}
</style>
